/**
 * 乘客行程公共
 */
define(["app", "js/services/MessageBox", "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "$stateParams", "MessageBox", "MuseService"];

    function common ($scope, $state, $modal, $stateParams, MessageBox, MuseService) {
        /**
         * 获取乘客行程状态
         */
        $scope.getTripStates = function () {
            MuseService.post(baseServices_restfulUrl + "trip/tripStates.json").success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.tripStates = data.data;
                    } else {
                        MessageBox.notify('获取乘客行程状态失败：' + data.message);
                    }
                });
        };
        $scope.getTripStates();

        var states = {
            '-1': "已取消",
            '0': "待出行",
            '5': "待发车",
            '10': "已出发",
            '20': "已到达终点",
            '30': "支付中",
            '50': "已完成"
        };

        $scope.getStateClass = function (trip) {
            if (trip && trip.state == 50) {
                return "badge bg-success"
            } else {
                return "badge"
            }
        }

        $scope.getStateName = function (trip) {
            return trip ? states[trip.state] : "未知";
        }
    }

    common.$inject = deps;
    return app.lazy.controller("TripCommonController", common);
    ;
});
